package com.rsxy.service.config;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.rsxy.service.handle.WxHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        WxHandlerInterceptor wxHandlerInterceptor = new WxHandlerInterceptor();
        List<String> addPath=new ArrayList<>();
        addPath.add("/product/**");
        List<String> ecPath=new ArrayList<>();
        ecPath.add("/wx/**");
        registry.addInterceptor(wxHandlerInterceptor).addPathPatterns(addPath).excludePathPatterns(ecPath);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
       // registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/upload/");
       registry.addResourceHandler("/upload/**").addResourceLocations("file:/var/local/upload/");
    }

}
